# -*- coding: utf-8 -*-

#定义列表
list1 = ['first',1,5.0,"test is running","ok today is no work","running"]

# 列表取值
print "list1[0]:", list1[0]
print "list1[1:3]:", list1[1:3]
print "list1[-1:]:", list1[-1:]
print "list1[1:2]:", list1[1:2]


#更新修改列表
print "list1[1]:", list1[1]
list1[1] = "this is test"
print "list1[1]:", list1[1]


# 直接通过切片更新列表
listok = ["this","is","test","test","is","running"]

print(listok)
print(listok[1:3])
listok[1:3] = ["new","append"]

print(listok)



# for 循环遍历
for var in list1:
    print(var)
   
# while 循环遍历 

length=len(list1)
var=0
while var<length:
    print(list1[var])
    var+=1
        

#删除列表元素
print list1
del list1[1]
print "已经删除了列表元素"
print list1

# 定义元组
tup1 = ('a','b','c','test is running')


#元组访问
print tup1
print tup1[0]

# 遍历 
for var in tup1:
    print(var)


#定义一个字典
dir = {'name':'zs','age':25,'sex':'man'}

print dir['name']

#定义一个默认值

print(dir.get('score','请重新定义该键和值'))

#修改字典

print dir

dir['name'] = 'ww'

print dir


#删除字典元素

print dir
del dir['name']
print dir

#删除字典
del dir
print dir

dir = {'name':'zs','age':25,'sex':'man'}

dir.clear()
print dir

print("clear is running ")

dir = {'name':'zs','age':25,'sex':'man'}

# 遍历键

for key in dir.keys():
    print(key)
    
# 遍历值 

for value in dir.values():
    print(value)

    
# 遍历元素

for item in dir.items():
    print(item)

# 遍历键值对

for key,value in dir.items():
    print(key,value)

    





